

#ifndef _Vector2D_H_
#define _Vector2D_H_

class Vector2D {

  public:

    Vector2D();
    Vector2D(float init_x, float init_y);
    Vector2D(const Vector2D &var);

    void add(const Vector2D &var); // add the values of the given vector to self
    void scale(double scal); // multiply all components of current vector by the scalar

    float length(void) const;
    float length_2(void) const; // length squared

    float dist(const Vector2D &var) const; // euclidean distance between two vectors

    float dotProduct(const Vector2D &var) const;
    void normalise(void); // make the length of this vector 1.0
 
    // rotate the vector by angle degrees in the clockwise direction. vector should be normalised.
    void rotate(float angle); 
 
    // assumes current vector and input var are normalised 
    float angleBetween(const Vector2D &var) const; 

    void printString(void) const;
    


    float x, y;
};


inline Vector2D operator+(const Vector2D &var1, const Vector2D &var2){
    return Vector2D(var1.x+var2.x, var1.y+var2.y);
}

inline bool operator==(const Vector2D &var1, const Vector2D &var2){
    return var1.x==var2.x && var1.y==var2.y;
}

inline bool operator!=(const Vector2D &var1, const Vector2D &var2){
    return ! (var1 == var2);
}

inline Vector2D operator-(const Vector2D &var1, const Vector2D &var2){
    return Vector2D(var1.x-var2.x, var1.y-var2.y);
}

inline Vector2D operator*(const Vector2D &var, float scal){
    return Vector2D(var.x*scal, var.y*scal);
}

inline Vector2D operator*(float scal, const Vector2D &var){
    return Vector2D(var.x*scal, var.y*scal);
}

#endif

